package com.budwk.app.miniapp.controllers.admin;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.http.HttpRequest;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.util.DateUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.budwk.app.fetchdata.models.HttpClientUtil;
import com.budwk.app.miniapp.models.WxMsg;
import com.budwk.app.miniapp.models.WxVolunteer;
import com.budwk.app.miniapp.utils.HttpUtils;
import com.budwk.app.miniapp.utils.MailUtils;
import com.budwk.starter.common.page.Pagination;
import com.budwk.starter.common.result.Result;
import com.budwk.starter.common.result.ResultCode;
import com.budwk.starter.common.page.PageUtil;
import com.budwk.starter.log.annotation.SLog;
import com.budwk.starter.security.utils.SecurityUtil;
import com.budwk.app.miniapp.models.WxSpiderEmergencyInformation;
import com.budwk.app.miniapp.services.WxspideremergencyinformationService;
import org.apache.commons.lang3.StringUtils;
import org.nutz.dao.Cnd;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.*;
import org.nutz.lang.Strings;
import com.budwk.starter.common.openapi.annotation.*;
import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.text.Position;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

@IocBean
@At("/platform/miniapp/EmergencyInformation")
@ApiDefinition(tag = "微信小程序-舆论/预警相关推荐")
@Slf4j
public class WxspideremergencyinformationController {
    private final static Map<String, String> typeMap = new HashMap<>();

    @Inject
    private WxspideremergencyinformationService wxSpiderEmergencyInformationService;


    @At("/list")
    @Ok("json")
    @POST
    @ApiOperation(name = "分页查询应急信息抓取数据库")
    @ApiFormParams(
            value = {
                    @ApiFormParam(name = "pageNo", example = "1", description = "页码", type = "integer"),
                    @ApiFormParam(name = "pageSize", example = "10", description = "页大小", type = "integer"),
                    @ApiFormParam(name = "pageOrderName", example = "createdAt", description = "排序字段"),
                    @ApiFormParam(name = "pageOrderBy", example = "descending", description = "排序方式")
            },
            implementation = WxSpiderEmergencyInformation.class
    )
    @ApiResponses(
            implementation = WxSpiderEmergencyInformation.class
    )
    public Result<?> list(@Param("..") WxSpiderEmergencyInformation bean,
                          @Param("pageNo") int pageNo,
                          @Param("pageSize") int pageSize,
                          @Param("pageOrderName") String pageOrderName,
                          @Param("pageOrderBy") String pageOrderBy) {
        Cnd cnd = Cnd.NEW();
        if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderBy)) {
            cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
        }
        if (bean.getInformationtitle() != null && Strings.isNotBlank(bean.getInformationtitle().toString())) {
            cnd.and("informationtitle", "=", bean.getInformationtitle());
        }
        if (bean.getInformationcontent() != null && Strings.isNotBlank(bean.getInformationcontent().toString())) {
            cnd.and("informationcontent", "=", bean.getInformationcontent());
        }
        if (bean.getProvince() != null && Strings.isNotBlank(bean.getProvince().toString())) {
            cnd.and("province", "=", bean.getProvince());
        }
        if (bean.getCity() != null && Strings.isNotBlank(bean.getCity().toString())) {
            cnd.and("city", "=", bean.getCity());
        }
        if (bean.getStreet() != null && Strings.isNotBlank(bean.getStreet().toString())) {
            cnd.and("district", "=", bean.getStreet());
        }
        if (bean.getStreet() != null && Strings.isNotBlank(bean.getStreet().toString())) {
            cnd.and("street", "=", bean.getStreet());
        }
        if (bean.getInformationchannels() != null && Strings.isNotBlank(bean.getInformationchannels().toString())) {
            cnd.and("informationchannels", "=", bean.getInformationchannels());
        }
        if (bean.getReleasetime() != null && Strings.isNotBlank(bean.getReleasetime().toString())) {
            cnd.and("releasetime", "=", bean.getReleasetime());
        }
        if (bean.getAddtime() != null && Strings.isNotBlank(bean.getAddtime().toString())) {
            cnd.and("addtime", "=", bean.getAddtime());
        }
        if (bean.getAddperson() != null && Strings.isNotBlank(bean.getAddperson().toString())) {
            cnd.and("addperson", "=", bean.getAddperson());
        }
        if (bean.getCreatedate() != null && Strings.isNotBlank(bean.getCreatedate().toString())) {
            cnd.and("createdate", "=", bean.getCreatedate());
        }
        if (bean.getInformationmedia() != null && Strings.isNotBlank(bean.getInformationmedia().toString())) {
            cnd.and("informationmedia", "=", bean.getInformationmedia());
        }
        if (bean.getAddphone() != null && Strings.isNotBlank(bean.getAddphone().toString())) {
            cnd.and("addphone", "=", bean.getAddphone());
        }
        if (bean.getLongitude() != null && Strings.isNotBlank(bean.getLongitude().toString())) {
            cnd.and("longitude", "=", bean.getLongitude());
        }
        if (bean.getLatitude() != null && Strings.isNotBlank(bean.getLatitude().toString())) {
            cnd.and("latitude", "=", bean.getLatitude());
        }
        if (bean.getPicurl() != null && Strings.isNotBlank(bean.getPicurl().toString())) {
            cnd.and("picurl", "=", bean.getPicurl());
        }
        if (bean.getDisasterType() != null && Strings.isNotBlank(bean.getDisasterType().toString())) {
            cnd.and("disaster_type", "=", bean.getDisasterType());
        }
        if (bean.getDisasterAddress() != null && Strings.isNotBlank(bean.getDisasterAddress().toString())) {
            cnd.and("disaster_address", "=", bean.getDisasterAddress());
        }
        if (bean.getDisasterClass() != null && Strings.isNotBlank(bean.getDisasterClass().toString())) {
            cnd.and("disaster_class", "=", bean.getDisasterClass());
        }
        if (bean.getEventPicUrl() != null && Strings.isNotBlank(bean.getEventPicUrl().toString())) {
            cnd.and("event_pic_url", "=", bean.getEventPicUrl());
        }
        if (bean.getDisasterStatus() != null && Strings.isNotBlank(bean.getDisasterStatus().toString())) {
            cnd.and("disaster_status", "=", bean.getDisasterStatus());
        }
        if (bean.getVideoUrl() != null && Strings.isNotBlank(bean.getVideoUrl().toString())) {
            cnd.and("video_url", "=", bean.getVideoUrl());
        }
        if (bean.getIsshow() != null && Strings.isNotBlank(bean.getIsshow().toString())) {
            cnd.and("isshow", "=", bean.getIsshow());
        }
        Pagination pagination = wxSpiderEmergencyInformationService.listPage(pageNo, pageSize, cnd);
        List<WxSpiderEmergencyInformation> oldList = pagination.getList(WxSpiderEmergencyInformation.class);
        List<WxSpiderEmergencyInformation> newList = new ArrayList<>();
//        for (int i = 0; i < oldList.size(); i++) {
//            WxSpiderEmergencyInformation vo = oldList.get(i);
//            if ("贵州省气象局".equals(oldList.get(i).getInformationmedia()) || "国家预警信息发布中心".equals(oldList.get(i).getInformationmedia())) {
//                vo.setInformationcontent(vo.getInformationcontent() + "(关注东方祥云小程序，掌握实时预警信息)");
//            }
//            newList.add(vo);
//        }
//        pagination.setList(newList);
        return Result.data(pagination);
    }

    /**
     * 导出应急信息抓取数据库列表
     */

/*    @Log(title = "应急信息抓取数据库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(WxSpiderEmergencyInformationBo bo, HttpServletResponse response) {
        List<WxSpiderEmergencyInformationVo> list = iWxSpiderEmergencyInformationService.queryList(bo);
        ExcelUtil.exportExcel(list, "应急信息抓取数据库", WxSpiderEmergencyInformationVo.class, response);
    }*/

    /**
     * 导出应急信息抓取数据库列表 抖音接口
     */
/*    @GetMapping("/dataExport")
    public void download(HttpServletResponse response,WxSpiderEmergencyInformationBo bo) throws IOException {
        // 直接用浏览器或者用postman
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        response.setCharacterEncoding("utf-8");
        // URLEncoder.encode可以防止中文乱码
        String fileName = URLEncoder.encode("应急信息抓取数据库"+ UUID.randomUUID(), "UTF-8").replaceAll("\\+", "%20");
        response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
        Timestamp timestamp = new Timestamp(System.currentTimeMillis());
        timestamp.setHours(timestamp.getHours()-24);
        timestamp.setMinutes(0);
        timestamp.setSeconds(0);
        timestamp.setNanos(0);
        bo.setReleasetimebegin(timestamp);
        bo.setDisasterStatus("灾害");
        //  bo.setDisasterClass("export");

        List<WxSpiderEmergencyInformationVoExcel> rlist = new ArrayList<>();
        List<WxSpiderEmergencyInformationVo> list = iWxSpiderEmergencyInformationService.queryList(bo);

        for (int i = 0; i < list.size(); i++) {
            WxSpiderEmergencyInformationVoExcel vo  = new WxSpiderEmergencyInformationVoExcel();
            BeanCopyUtils.copy(list.get(i), vo);
            if(vo.getDisasterType().indexOf("(")>0)
            {
                vo.setDisasterType(vo.getDisasterType().substring(0,vo.getDisasterType().indexOf("(")));
            }
            if(vo.getDisasterType().indexOf("巾")>0)
            {
                vo.setDisasterType(vo.getDisasterType().replace("巾",""));
            }

            rlist.add(vo);
        }

        EasyExcel.write(response.getOutputStream(), Position.class).sheet("应急信息抓取数据库").doWrite(rlist);
    }*/
    @At("/add")
    @Ok("json")
    @POST
    @ApiOperation(name = "新增应急信息抓取数据库")
    @ApiFormParams(
            implementation = WxSpiderEmergencyInformation.class
    )
    @ApiResponses
    @SLog(tag = "新增应急信息抓取数据库", value = "${args[0].id}")
    @SaCheckLogin
    public Result<?> create(@Param("..") WxSpiderEmergencyInformation wxSpiderEmergencyInformation, HttpServletRequest req) {
        Date day = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        wxSpiderEmergencyInformation.setCreatedBy(SecurityUtil.getUserId());
        wxSpiderEmergencyInformation.setAddtime(sdf.format(day));
        wxSpiderEmergencyInformation.setReleasetime(Timestamp.valueOf(sdf.format(day)));
        // 不显示
        wxSpiderEmergencyInformation.setIsshow("1");
        wxSpiderEmergencyInformationService.insert(wxSpiderEmergencyInformation);
        return Result.success();
    }

    @At("/update")
    @Ok("json")
    @POST
    @ApiOperation(name = "修改WxSpiderEmergencyInformation")
    @ApiFormParams(
            implementation = WxSpiderEmergencyInformation.class
    )
    @ApiResponses
    @SLog(tag = "修改应急信息抓取数据库", value = "${args[0].id}")
    @SaCheckLogin
    public Result<?> update(@Param("..") WxSpiderEmergencyInformation wxSpiderEmergencyInformation, HttpServletRequest req) {
        wxSpiderEmergencyInformation.setUpdatedAt(Long.valueOf(DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss")));
        wxSpiderEmergencyInformation.setUpdatedBy(SecurityUtil.getUserId());
        wxSpiderEmergencyInformationService.updateIgnoreNull(wxSpiderEmergencyInformation);
        return Result.success();
    }

    @At("/get")
    @Ok("json")
    @POST
    @ApiOperation(name = "获取应急信息抓取数据库")
    @ApiFormParams(
            {
                    @ApiFormParam(name = "id", description = "唯一标识", required = true, check = true)
            }
    )
    @SaCheckLogin
    public Result<?> getData(@Param("id") String id, HttpServletRequest req) {
        WxSpiderEmergencyInformation wxSpiderEmergencyInformation = wxSpiderEmergencyInformationService.fetch(id);
        if (wxSpiderEmergencyInformation == null) {
            return Result.error(ResultCode.NULL_DATA_ERROR);
        }
        if (wxSpiderEmergencyInformation.getInformationmedia().equals("贵州省气象局")
                || wxSpiderEmergencyInformation.getInformationmedia().equals("国家预警信息发布中心")) {
            wxSpiderEmergencyInformation.setInformationcontent(wxSpiderEmergencyInformation.getInformationcontent() + "(关注东方祥云小程序，掌握实时预警信息)");
        }
        return Result.data(wxSpiderEmergencyInformation);
    }

    @At("/delete")
    @Ok("json")
    @POST
    @ApiOperation(name = "删除应急信息抓取数据库")
    @ApiFormParams(
            {
                    @ApiFormParam(name = "id", description = "唯一标识", required = true, check = true)
            }
    )
    @SLog(tag = "删除应急信息抓取数据库", value = "${args[0]}")
    @SaCheckLogin
    public Result<?> delete(@Param("ids") String[] ids, HttpServletRequest req) {
        wxSpiderEmergencyInformationService.delete(ids);
        return Result.success();
    }


    /**
     * 中囯地震台网
     */
    @At("/earthQuakeData")
    @Ok("json")
    @GET
    @ApiOperation(name = "中囯地震台网数据")
    @SLog(tag = "中囯地震台网数据", value = "${args[0]}")
    @SaCheckLogin
    public Result<?> earthQuakeData() {
        try {
            System.out.println("中国地震台网: " + new Date());
            List<WxSpiderEmergencyInformation> emergencyInfoList = new ArrayList<>();

            String result = HttpUtils.getRequest("http://140.210.211.155:8089/datapi/earthquakedata/query?pageNumber=1&pageSize=50");
            JSONObject dataJson = JSONObject.parseObject(result);
            JSONObject pagerJson = dataJson.getJSONObject("data");
            JSONArray listJson = pagerJson.getJSONArray("list");
            try {
                for (int i = 0; i < listJson.size(); i++) {
                    JSONObject item = listJson.getJSONObject(i);
                    WxSpiderEmergencyInformation infoBo = new WxSpiderEmergencyInformation();
                    infoBo.setInformationtitle(item.getString("LOCATION_C") + "发生了" + item.getString("M") + "级地震");
                    String startDate = item.getString("O_TIME").replaceAll("/", "-");
                    infoBo.setReleasetime(Timestamp.valueOf(startDate));

                    List<WxSpiderEmergencyInformation> list = new ArrayList<>(); // iWxSpiderEmergencyInformationService.queryList(infoBo);
                    if (list.size() < 1) {
                        Thread.sleep(3000);
                        JSONObject addressInfo = getAddressInfo(item.getString("EPI_LON"), item.getString("EPI_LAT"));
                        JSONObject jsonresult = addressInfo.getJSONObject("result");
                        if (null != jsonresult) {
                            String formatted_address = jsonresult.getString("formatted_address");
                            JSONObject addressComponent = jsonresult.getJSONObject("addressComponent");
                            String province = addressComponent.getString("province");
                            String city = addressComponent.getString("city");
                            String county = addressComponent.getString("county");
                            // String district = addressComponent.getString("road");
                            // String poi = addressComponent.getString("poi");
                            if (province != null && city != null && county != null) {
                                infoBo.setDisasterAddress(province + city + county);
                            }
                            if (province == "" || province == null || province.equals("全球")) {
                                infoBo.setDisasterAddress(item.getString("LOCATION_C") + "【国外】");
                            }
                            infoBo.setProvince(province);
                            infoBo.setCity(city);
                            infoBo.setDistrict(county);
                            // infoBo.setStreet(district);
//                                if(poi!=null&&poi.contains("村"))
//                                {
//                                    infoBo.setStreet(poi);
//                                }
                        } else if (item.getString("LOCATION_C").indexOf("台湾") > 0) {
                            infoBo.setDisasterAddress(item.getString("LOCATION_C"));
                            infoBo.setProvince("台湾省");
                            if (item.getString("LOCATION_C").indexOf("省") > 0) {
                                infoBo.setProvince(item.getString("LOCATION_C").substring(0, item.getString("LOCATION_C").indexOf("省") + 1));
                            }
                            infoBo.setCity("");
                            if (item.getString("LOCATION_C").indexOf("市") > 0) {
                                infoBo.setProvince(item.getString("LOCATION_C").substring(0, item.getString("LOCATION_C").indexOf("市") + 1));
                            }
                            infoBo.setDistrict("");
                            if (item.getString("LOCATION_C").indexOf("县") > 0) {
                                infoBo.setProvince(item.getString("LOCATION_C").substring(0, item.getString("LOCATION_C").indexOf("县") + 1));
                            }
//                                infoBo.setStreet("");
//                                if(item.getString("LOCATION_C").indexOf("路")>0)
//                                {
//                                    infoBo.setProvince(item.getString("LOCATION_C").substring(0,item.getString("LOCATION_C").indexOf("路")+1));
//                                }
                        } else {
                            infoBo.setProvince("国外");
                            infoBo.setCity("国外");
                            infoBo.setDistrict("国外");
                            //infoBo.setStreet("国外");
                            infoBo.setDisasterAddress("国外");
                        }
                        if (infoBo.getProvince() == null || infoBo.getProvince().equals("")) {
                            infoBo.setProvince("国外");
                            infoBo.setCity("国外");
                            infoBo.setDistrict("国外");
                            infoBo.setDisasterAddress("国外");
                        }
                        infoBo.setDisasterStatus("灾害");
                        String prefix = Double.valueOf(item.getString("EPI_LON")) > 0 ? "东经" : "西经";
                        String prefixs = Double.valueOf(item.getString("EPI_LAT")) > 0 ? "北纬" : "南纬";

                        infoBo.setInformationcontent(startDate + " " + item.getString("LOCATION_C") + "【" + prefix + Math.abs((Double.valueOf(item.getString("EPI_LON")))) +
                                "," + prefixs + Math.abs((Double.valueOf(item.getString("EPI_LAT")))) + " 】发生了" + item.getString("M") + "级地震，震源深度" + item.getString("EPI_DEPTH") + "千米。");
                        infoBo.setInformationmedia("中国地震台网");
                        infoBo.setInformationchannels("中国地震台网");
                        infoBo.setDisasterType("地震");
                        infoBo.setLongitude(item.getString("EPI_LON"));
                        infoBo.setLatitude(item.getString("EPI_LAT"));
                        infoBo.setDisasterClass(item.getString("M"));
                        //infoBo.setPicurl("震源深度"+item.getString("EPI_DEPTH")+"千米。");
                        infoBo.setPicurl("dizheng.png");
                        infoBo.setAddperson("祥云AI");
                        infoBo.setAddphone("18888888888");
                        Date day = new Date();
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        infoBo.setAddtime(sdf.format(day));
                        emergencyInfoList.add(infoBo);

                        //iWxSpiderEmergencyInformationService.updateBatch(emergencyInfoList);
                        emergencyInfoList = new ArrayList<>();
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.success(true);
    }

    /**
     * 根据经纬度获取地址信息
     *
     * @param longitude 经度
     * @param latitude  纬度
     * @return 地址信息，包括省、市、区等
     */
    public static JSONObject getAddressInfo(String longitude, String latitude) {
        if ("".equals(longitude) || "".equals(latitude) || null == longitude || null == latitude) {
            return new JSONObject();
        }
        String urlString = "http://api.tianditu.gov.cn/geocoder?postStr={'lon':" + longitude + ",'lat':" + latitude + ",'ver':1}&type=geocode&tk=25a77f643d94d6acbd6c1b79cfeeda69";
        System.out.println(urlString);
        StringBuilder result = new StringBuilder();
        BufferedReader in = null;
        try {
            URL url = new URL(urlString);
            URLConnection connection = url.openConnection();
            connection.setRequestProperty("Accept-Charset", "UTF-8");
            connection.setConnectTimeout(5000);
            connection.connect();
            in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
            String line;
            while ((line = in.readLine()) != null) {
                result.append(line);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (in != null) {
                    in.close();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return JSONObject.parseObject(result.toString());
    }


    //根据地名查经纬度
    public static ConcurrentHashMap getLatAndLngByAddr(String addr) {
        ConcurrentHashMap hmap = new ConcurrentHashMap();
        try {
            String result = "";
            addr = addr.replace(" ", "").replace("#", "").replace("中国", "");
            String queryStr = "http://api.tianditu.gov.cn/geocoder?ds=%7B'keyWord':'" + addr + "'%7D&tk=" + "25a77f643d94d6acbd6c1b79cfeeda69";
            /**
             *HttpClientUtil获取路径：
             *https://blog.csdn.net/weixin_40052298/article/details/123347111?spm=1001.2014.3001.5501
             */
            String info = HttpClientUtil.get(queryStr);
            System.out.println(info);
            if (StringUtils.isNotBlank(info)) {
                JSONObject resultJson = JSON.parseObject(info);
                if (!"无结果".equals(resultJson.get("msg"))) {
                    JSONObject locationObj = (JSONObject) resultJson.get("location");
                    //纬度
                    String lat = locationObj.get("lat") + "";
                    //经度
                    String lng = locationObj.get("lon") + "";
                    hmap.put("lng", lng);
                    hmap.put("lat", lat);
                    result = "经度：" + lng + "\n纬度：" + lat;
                }
            }/*"经度：106.566386 纬度：26.620078"*/
            return hmap;
        } catch (Exception e) {
            return hmap;
        }
    }


    /*
     * 根据预警查询相关舆情(分页)
     * */
    @At("/getRelatedSentiment")
    @Ok("json")
    @POST
    @ApiOperation(name = "根据预警查询相关舆情")
    @ApiFormParams(
            {
                    @ApiFormParam(name = "province", description = "省", required = true, check = true),
                    @ApiFormParam(name = "city", description = "市", required = true, check = true),
                    @ApiFormParam(name = "district", description = "区县", required = true, check = true),
                    @ApiFormParam(name = "releasetime", description = "应急发布时间", required = true, check = true),
                    @ApiFormParam(name = "disasterType", description = "灾害类型", required = true, check = true)
            }
    )
    @ApiResponses(
            implementation = WxSpiderEmergencyInformation.class
    )
    @SaCheckLogin
    public Result<?> getRelatedSentiment(@Param("..") WxSpiderEmergencyInformation queryDTO,
                                         @Param("pageNo") int pageNo,
                                         @Param("pageSize") int pageSize,
                                         @Param("pageOrderName") String pageOrderName,
                                         @Param("pageOrderBy") String pageOrderBy) {
        Cnd cnd = Cnd.NEW();
        if (queryDTO.getProvince() != null && Strings.isNotBlank(queryDTO.getProvince().toString())) {
            cnd.and("province", "=", queryDTO.getProvince());
        }
        if (queryDTO.getCity() != null && Strings.isNotBlank(queryDTO.getCity().toString())) {
            cnd.and("city", "=", queryDTO.getCity());
        }
        if (queryDTO.getDistrict() != null && Strings.isNotBlank(queryDTO.getDistrict().toString())) {
            cnd.and("district", "=", queryDTO.getDistrict());
        }
        if (queryDTO.getStreet() != null && Strings.isNotBlank(queryDTO.getStreet().toString())) {
            cnd.and("street", "=", queryDTO.getStreet());
        }
        if (queryDTO.getDisasterType() != null && Strings.isNotBlank(queryDTO.getDisasterType().toString())) {
            cnd.and("disasterType", "=", queryDTO.getDisasterType());
        }
        if (queryDTO.getReleasetime() != null && Strings.isNotBlank(queryDTO.getReleasetime().toString())) {
            cnd.and("releasetime", "=", queryDTO.getReleasetime());
        }

        cnd.and("disasterStatus", "=", "舆情");
        cnd.and("isshow", "=", "0");
        cnd.orderBy("releasetime", "desc");
        return Result.success(wxSpiderEmergencyInformationService.listPage(pageNo, pageSize, cnd));
    }


    /**
     * 中国气象预警信息2
     *
     * @return
     */
    @At("/emergencyInformation2")
    @Ok("json")
    @GET
    @ApiOperation(name = "中国气象预警信息2")
    @SaCheckLogin
    private Result<Void> emergencyInformation2() {
        Date day2 = new Date();
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        day2.setHours(day2.getHours() - 72);

        try {
            System.out.println("国家预警信息发布中心预警信息: " + new Date());
            List<WxSpiderEmergencyInformation> emergencyInfoList = new ArrayList<>();
            String result = HttpUtils.getRequest("https://weather.cma.cn/api/map/alarm?adcode=");
            JSONObject dataJson = JSONObject.parseObject(result);
            //String  picUrl ="https://dfsj-standard.obs.cn-south-1.myhuaweicloud.com/dfxy_disaster/";
            JSONArray listJson = dataJson.getJSONArray("data");
            for (int i = 0; i < listJson.size(); i++) {

                WxSpiderEmergencyInformation infoBo = new WxSpiderEmergencyInformation();
                JSONObject item = listJson.getJSONObject(i);

                if (item.getString("headline").contains("潍坊市")) {
                    infoBo.setInformationtitle(item.getString("headline"));
                    String startDate = item.getString("effective").replaceAll("/", "-") + ":00";
                    infoBo.setReleasetime(Timestamp.valueOf(startDate));

                    Timestamp send_time = Timestamp.valueOf(startDate); //三天之前的数据不入库
                    Timestamp start = Timestamp.valueOf(sdf2.format(day2));
                    if (send_time.compareTo(start) < 0) continue;

                    JSONObject addressInfo = null;
                    JSONObject jsonresult = null;
                    List<WxSpiderEmergencyInformation> list = new ArrayList<>(); // iWxSpiderEmergencyInformationService.queryList(infoBo);
                    infoBo.setLongitude(item.getString("longitude"));
                    infoBo.setLatitude(item.getString("latitude"));
                    if (list.size() < 1) {
                        //Thread.sleep(3000);
                        addressInfo = getAddressInfo(item.getString("longitude"), item.getString("latitude"));
                        if (addressInfo != null) {
                            jsonresult = addressInfo.getJSONObject("result");
                            if (jsonresult != null) {
                                String formatted_address = jsonresult.getString("formatted_address");
                                JSONObject addressComponent = jsonresult.getJSONObject("addressComponent");
                                String province = addressComponent.getString("province");
                                String city = addressComponent.getString("city");
                                String county = addressComponent.getString("county");
                                // String district = addressComponent.getString("road");
                                // String poi = addressComponent.getString("poi");
                                if (province != null && city != null && county != null) {
                                    infoBo.setDisasterAddress(province + city + county);
                                }
                                if (province == "" || province == null || province.equals("全球")) {
                                    infoBo.setDisasterAddress("【国外】");
                                }

                                infoBo.setProvince(province);
                                infoBo.setCity(city);
                                infoBo.setDistrict(county);
//                                infoBo.setStreet(district);
//                                if (poi != null && poi.contains("村")) {
//                                    infoBo.setStreet(poi);
//                                }


                            } else {
                                // infoBo.setDisasterAddress(item.getString("headline"));
                                infoBo.setProvince("");
                                if (item.getString("headline").indexOf("省") > 0) {
                                    infoBo.setProvince(item.getString("headline").substring(0, item.getString("headline").indexOf("省") + 1));
                                }
                                infoBo.setCity("");
                                if (item.getString("headline").indexOf("市") > 0) {
                                    infoBo.setCity(item.getString("headline").substring(0, item.getString("headline").indexOf("市") + 1));
                                }
                                infoBo.setDistrict("");
                                if (item.getString("headline").indexOf("县") > 0) {
                                    infoBo.setDistrict(item.getString("headline").substring(0, item.getString("headline").indexOf("县") + 1));
                                }
                                if (item.getString("headline").indexOf("区") > 0) {
                                    infoBo.setDistrict(item.getString("headline").substring(0, item.getString("headline").indexOf("区") + 1));
                                }
                                // infoBo.setDisasterAddress(infoBo.get + city + county);
                                // infoBo.setStreet("");
                            }

                        } else {
                            // infoBo.setDisasterAddress(item.getString("headline"));
                            infoBo.setProvince("");
                            if (item.getString("headline").indexOf("省") > 0) {
                                infoBo.setProvince(item.getString("headline").substring(0, item.getString("headline").indexOf("省") + 1));
                            }
                            infoBo.setCity("");
                            if (item.getString("headline").indexOf("市") > 0) {
                                infoBo.setCity(item.getString("headline").substring(0, item.getString("headline").indexOf("市") + 1));
                            }
                            infoBo.setDistrict("");
                            if (item.getString("headline").indexOf("县") > 0) {
                                infoBo.setDistrict(item.getString("headline").substring(0, item.getString("headline").indexOf("县") + 1));
                            }
                            if (item.getString("headline").indexOf("区") > 0) {
                                infoBo.setDistrict(item.getString("headline").substring(0, item.getString("headline").indexOf("区") + 1));
                            }
                            // infoBo.setDisasterAddress(infoBo.get + city + county);
                            // infoBo.setStreet("");
                        }

                        if ((infoBo.getProvince() == null || infoBo.getProvince().equals("")) && (infoBo.getCity() == null || infoBo.getCity().equals("")) && (infoBo.getDistrict() == null || infoBo.getDistrict().equals(""))) {
                            if (item.getString("headline").indexOf("气象台") > 0) {
                                infoBo.setDistrict(item.getString("headline").substring(0, item.getString("headline").indexOf("气象台")));
                            }
                            if (infoBo.getDistrict() == null || infoBo.getDistrict().equals("")) {
                                if (item.getString("headline").indexOf("气象局") > 0) {
                                    infoBo.setDistrict(item.getString("headline").substring(0, item.getString("headline").indexOf("气象局")));
                                }
                            }
                            if (infoBo.getDistrict() == null || infoBo.getDistrict().equals("")) {
                                infoBo.setDistrict(item.getString("headline").substring(0, 2));
                            }
                        }

                        if (infoBo.getProvince() == null || infoBo.getProvince().length() < 2 || infoBo.getProvince() == "") {
                            ConcurrentHashMap map = new ConcurrentHashMap();
                            if (infoBo.getCity() != null && infoBo.getCity().length() > 2) {
                                map = getLatAndLngByAddr(infoBo.getCity());
                            }
                            if (infoBo.getDistrict() != null && infoBo.getDistrict().length() > 1) {
                                map = getLatAndLngByAddr(infoBo.getDistrict());
                            }
                            if (map.get("lng") != null && map.get("lat") != null) {
                                infoBo.setLongitude(String.valueOf(map.get("lng")));
                                infoBo.setLatitude(String.valueOf(map.get("lat")));
                                addressInfo = getAddressInfo(String.valueOf(map.get("lng")), String.valueOf(map.get("lat")));
                                if (addressInfo != null) {
                                    jsonresult = addressInfo.getJSONObject("result");
                                    if (jsonresult != null) {
                                        JSONObject addressComponent = jsonresult.getJSONObject("addressComponent");
                                        infoBo.setProvince(addressComponent.getString("province"));
                                        String city = addressComponent.getString("city");
                                        city = city.indexOf("省") > 0 ? city.substring(city.indexOf("省") + 1) : city;
                                        infoBo.setCity(city);
                                        if (infoBo.getDistrict() == null || infoBo.getDistrict().equals(""))
                                            infoBo.setDistrict(addressComponent.getString("county"));
                                        if ((infoBo.getProvince() == null || infoBo.getProvince().equals("")) && jsonresult.getString("formatted_address") != null && jsonresult.getString("formatted_address").indexOf("省") > 0) {
                                            infoBo.setProvince(jsonresult.getString("formatted_address").substring(0, jsonresult.getString("formatted_address").indexOf("省") + 1));
                                        }
                                        infoBo.setDisasterAddress(addressComponent.getString("province") + addressComponent.getString("city") + addressComponent.getString("county"));
                                    }
                                }
                            }
                        }

                        if ((infoBo.getCity() == null || infoBo.getCity().equals("")) && infoBo.getDistrict() != null) {
                            infoBo.setCity(infoBo.getDistrict());
                        }

                        infoBo.setInformationcontent(item.getString("description") + " （预警信息来源：国家预警信息发布中心）");
                        infoBo.setInformationmedia("国家预警信息发布中心");

                        infoBo.setDisasterStatus("灾害");
                        infoBo.setInformationchannels(item.getString("headline").indexOf("发布") > 0 ? item.getString("headline").substring(0, item.getString("headline").indexOf("发布")) : item.getString("headline"));
                        if (infoBo.getInformationtitle().equals(infoBo.getInformationchannels()) || item.getString("headline").indexOf("气象台") > 0) {
                            infoBo.setInformationchannels(item.getString("headline").indexOf("气象台") > 0 ? item.getString("headline").substring(0, item.getString("headline").indexOf("气象台") + 3) : item.getString("headline"));
                        }
                        if (infoBo.getInformationtitle().equals(infoBo.getInformationchannels()) || item.getString("headline").indexOf("气象局") > 0) {
                            infoBo.setInformationchannels(item.getString("headline").indexOf("气象局") > 0 ? item.getString("headline").substring(0, item.getString("headline").indexOf("气象局") + 3) : item.getString("headline"));
                        }

                        infoBo.setPicurl(item.getString("type") + ".png");

                        String type = typeMap.get(item.getString("type"));
                        if (type != null && type.indexOf("（") > 0 && type.lastIndexOf("）") > 0) {
                            infoBo.setDisasterClass(type.substring(type.indexOf("（") + 1, type.indexOf("）")));
                            infoBo.setDisasterType(type.substring(0, type.indexOf("（")));
                        }
                        if (infoBo.getPicurl() != null && (infoBo.getPicurl().contains("UNKNOWN") || infoBo.getPicurl().contains("11D08") || infoBo.getPicurl().contains("11D08") || infoBo.getPicurl().contains("11A51")))//
                        {
                            infoBo.setPicurl("other.png");
                        }
                        if (infoBo.getDisasterType() != null && infoBo.getDisasterType().equals("其他")) //
                        {
                            infoBo.setPicurl("other.png");
                        }
                        //不等于高温红色，干旱红色
                        if (infoBo.getDisasterClass() != null && infoBo.getDisasterClass().equals("红色预警") && !item.getString("type").equals("11B09_RED") && !item.getString("type").equals("11B22_RED")) ////发邮件
                        {
                            MailUtils.sendText("1750632126@qq.com,yiyi5475@163.com", infoBo.getInformationtitle(), infoBo.getDisasterAddress());
                        }
                        //去掉异常类型
                        if (infoBo.getDisasterType() != null && infoBo.getDisasterType().indexOf("(") > 0) {
                            infoBo.setDisasterType(infoBo.getDisasterType().substring(0, infoBo.getDisasterType().indexOf("(")));
                        }
                        if (infoBo.getDisasterType() != null && infoBo.getDisasterType().indexOf("巾") > 0) {
                            infoBo.setDisasterType(infoBo.getDisasterType().replace("巾", ""));
                        }
                        infoBo.setAddperson("祥云AI");
                        infoBo.setAddphone("18888888888");
                        //添加人等
                        Date day = new Date();
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        infoBo.setAddtime(sdf.format(day));

                        emergencyInfoList.add(infoBo);

                        // iWxSpiderEmergencyInformationService.updateBatch(emergencyInfoList);
                        emergencyInfoList.clear();
                    }

                }
            }
            // iWxSpiderEmergencyInformationService.updateBatch(emergencyInfoList);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.success();
    }


    /**
     * 贵州省气象局
     *
     * @return
     */
    @At("/parseMeteorologicalwarning")
    @Ok("json")
    @GET
    @ApiOperation(name = "贵州省气象局")
    @SaCheckLogin
    private Result<Void> parseMeteorologicalwarning() {
        System.out.println("贵州省气象预警信息: " + new Date());
        int pageNumber = 1, pageSize = 50;
        List<WxSpiderEmergencyInformation> warningBoList = new ArrayList<>();
        while (true) {
            Map<String, Object> params = new HashMap<>();
            params.put("pageNumber", pageNumber);
            params.put("pageSize", pageSize);
            String result = HttpUtils.getRequest("http://140.210.211.155:8089/datapi/meteorologicalwarning/query", params);
            JSONObject jsonObject = JSONObject.parseObject(result);
            JSONObject dataJson = jsonObject.getJSONObject("data");
            JSONObject pagerJson = dataJson.getJSONObject("pager");
            int pageCount = pagerJson.getInteger("pageCount");
            if (pageNumber > pageCount) {
                break;
            }

            Date day2 = new Date();
            SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            day2.setHours(day2.getHours() - 72);

            JSONArray listJson = dataJson.getJSONArray("list");
            for (int i = 0; i < listJson.size(); i++) {
                JSONObject item = listJson.getJSONObject(i);
                Timestamp send_time = ((Timestamp) item.getTimestamp("send_time"));
                Timestamp start = Timestamp.valueOf(sdf2.format(day2));
                if (send_time.compareTo(start) < 0) continue;

                WxSpiderEmergencyInformation warningBo = new WxSpiderEmergencyInformation();


                warningBo.setReleasetime(((Timestamp) item.getTimestamp("send_time"))); //发布时间 sender
                warningBo.setInformationtitle(item.getString("headline"));//标题


                List<WxSpiderEmergencyInformation> list = new ArrayList<>(); //iWxSpiderEmergencyInformationService.queryList(warningBo);
                if (list.size() < 1) {


                    try {
                        //Thread.sleep(3000);
                        String idStr = item.getString("identifier") + "-" + ((Timestamp) item.getTimestamp("send_time")).getTime();
                        String wholeName = typeMap.get(item.getString("identifier"));

                        if (StringUtils.isNotEmpty(wholeName)) {
                            String[] areas = wholeName.split("，");
                            warningBo.setProvince(areas[0]);
                            warningBo.setCity(areas.length < 2 ? null : areas[1]);
                            warningBo.setDistrict(areas.length < 3 ? null : areas[2]);
                        }

                        warningBo.setInformationchannels(item.getString("sender"));//气象局
                        warningBo.setInformationcontent(item.getString("description"));//内容
                        warningBo.setDisasterClass(typeMap.get(item.getString("severity")));
                        warningBo.setInformationtitle(item.getString("headline"));//标题
                        warningBo.setId(idStr);
                        if (warningBo.getInformationchannels().equals("白云区")) {
                            warningBo.setInformationchannels(item.getString("sender"));//气象局
                        }

                        JSONObject addressInfo = null;
                        JSONObject jsonresult = null;
                        if (item.getString("sender").contains("三沙")) {
                            warningBo.setInformationchannels(item.getString("sender"));//气象局


                            if (item.getString("headline").indexOf("省") > 0) {
                                warningBo.setProvince(item.getString("headline").substring(0, item.getString("headline").indexOf("省") + 1));
                            }
                            warningBo.setCity("");
                            if (item.getString("headline").indexOf("市") > 0) {
                                warningBo.setCity(item.getString("headline").substring(0, item.getString("headline").indexOf("市") + 1));
                            }
                            warningBo.setDistrict("");
                            if (item.getString("headline").indexOf("县") > 0) {
                                warningBo.setDistrict(item.getString("headline").substring(0, item.getString("headline").indexOf("县") + 1));
                            }
                            if (item.getString("headline").indexOf("区") > 0) {
                                warningBo.setDistrict(item.getString("headline").substring(0, item.getString("headline").indexOf("区") + 1));
                            }
                            if (item.getString("headline").indexOf("州") > 0) {
                                warningBo.setDistrict(item.getString("headline").substring(0, item.getString("headline").indexOf("州") + 1));
                            }


                            if (warningBo.getProvince() == null || warningBo.getProvince().length() < 2 || warningBo.getProvince() == "") {
                                ConcurrentHashMap map = new ConcurrentHashMap();
                                if (warningBo.getCity() != null && warningBo.getCity().length() > 2) {
                                    map = getLatAndLngByAddr(warningBo.getCity());
                                }
                                if (warningBo.getDistrict() != null && warningBo.getDistrict().length() > 2) {
                                    map = getLatAndLngByAddr(warningBo.getDistrict());
                                }
                                if (map.get("lng") != null && map.get("lat") != null) {
                                    warningBo.setLongitude(String.valueOf(map.get("lng")));
                                    warningBo.setLatitude(String.valueOf(map.get("lat")));
                                    addressInfo = getAddressInfo(String.valueOf(map.get("lng")), String.valueOf(map.get("lat")));
                                    if (addressInfo != null) {
                                        jsonresult = addressInfo.getJSONObject("result");
                                        if (jsonresult != null) {
                                            JSONObject addressComponent = jsonresult.getJSONObject("addressComponent");
                                            warningBo.setProvince(addressComponent.getString("province"));
                                            String city = addressComponent.getString("city");
                                            city = city.indexOf("省") > 0 ? city.substring(city.indexOf("省") + 1) : city;
                                            warningBo.setCity(city);
                                            warningBo.setDistrict(addressComponent.getString("county"));
                                            warningBo.setDisasterAddress(addressComponent.getString("province") + addressComponent.getString("city") + addressComponent.getString("county"));
                                        }
                                    }
                                }
                            }

                        }

                        warningBo.setProvince("贵州省");

                        if (warningBo.getDistrict() != null && warningBo.getDistrict().equals("贵州")) {
                            warningBo.setDistrict(null);
                        }

                        warningBo.setInformationmedia("贵州省气象局");

                        warningBo.setDisasterStatus("灾害");
                        if (item.getString("event_type") != null) {
                            warningBo.setPicurl(item.getString("event_type") + "_" + item.getString("severity").toUpperCase() + ".png");
                        } else {
                            warningBo.setPicurl("other.png");
                        }

                        //  warningBo.setEventPicUrl(item.getString("severity"));

                        String type = typeMap.get(item.getString("event_type"));
                        warningBo.setDisasterType(type);
                        if (type != null && type.indexOf("事件") > 0) {
                            warningBo.setDisasterType(type.replaceAll("事件", ""));
                        }
                        //没有类型的再处理
                        warningBo.setDisasterType(warningBo.getDisasterType() == null ? "其他" : warningBo.getDisasterType());
                        if (warningBo.getPicurl().contains("UNKNOWN") || warningBo.getDisasterType().equals("其他") || warningBo.getPicurl().contains("11D08")) //
                        {
                            warningBo.setPicurl("other.png");
                        }
                        if (warningBo.getDisasterClass().equals("红色预警")) //发邮件
                        {
                            MailUtils.sendText("850715177@qq.com,yiyi5475@163.com", warningBo.getInformationtitle(), warningBo.getDisasterAddress());
                        }
                        //不等于高温红色，干旱红色
                        if (warningBo.getDisasterClass() != null && warningBo.getDisasterClass().equals("红色预警") && !item.getString("type").equals("11B09_RED") && !item.getString("type").equals("11B22_RED")) ////发邮件
                        {
                            MailUtils.sendText("1750632126@qq.com,yiyi5475@163.com", warningBo.getInformationtitle(), warningBo.getDisasterAddress());
                        }
                        warningBo.setAddperson("祥云AI");
                        warningBo.setAddphone("15555555555");
                        //添加人等
                        Date day = new Date();
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        warningBo.setAddtime(sdf.format(day));

                        // emergencyInfoList.add(warningBo);


                        warningBoList.add(warningBo);
                        // iWxSpiderEmergencyInformationService.insertBatch(warningBoList);
                        // warningBoList.clear();

                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                }

            }
            pageNumber++;
        }
        return Result.success();
    }

    private void parseMeteorologicalwarning2() {
        int pageNumber = 1, pageSize = 50;
        List<WxSpiderEmergencyInformation> warningBoList = new ArrayList<>();
        while (true) {
            Map<String, Object> params = new HashMap<>();
            params.put("pageNumber", pageNumber);
            params.put("pageSize", pageSize);
            String result = HttpUtils.getRequest("http://10.10.0.13:8089/datapi/meteorologicalwarning/query", params);
            JSONObject jsonObject = JSONObject.parseObject(result);
            JSONObject dataJson = jsonObject.getJSONObject("data");
            JSONObject pagerJson = dataJson.getJSONObject("pager");
            int pageCount = pagerJson.getInteger("pageCount");
            if (pageNumber > pageCount) {
                break;
            }
            JSONArray listJson = dataJson.getJSONArray("list");
            for (int i = 0; i < listJson.size(); i++) {
                JSONObject item = listJson.getJSONObject(i);
                WxSpiderEmergencyInformation warningBo = new WxSpiderEmergencyInformation();
                Cnd cnd = Cnd.NEW();
                //发布时间
                cnd.and("releasetime", "=", ((Timestamp) item.getTimestamp("send_time")));
                //标题
                cnd.and("informationtitle", "=", item.getString("headline"));
                List<WxSpiderEmergencyInformation> list = wxSpiderEmergencyInformationService.query(cnd);
                if (list.size() < 1) {
                    try {
                        Thread.sleep(3000);
                        String idStr = item.getString("identifier") + "-" + ((Timestamp) item.getTimestamp("send_time")).getTime();
                        String wholeName = typeMap.get(item.getString("identifier"));
                        if (StringUtils.isNotEmpty(wholeName)) {
                            String[] areas = wholeName.split("，");
                            warningBo.setProvince(areas[0]);
                            warningBo.setCity(areas.length < 2 ? null : areas[1]);
                            warningBo.setDistrict(areas.length < 3 ? null : areas[2]);
                        }
                        warningBo.setInformationcontent(item.getString("description"));//内容
                        warningBo.setDisasterClass(typeMap.get(item.getString("severity")));
                        warningBo.setId(idStr);
                        warningBo.setInformationchannels(item.getString("sender"));//气象局
                        JSONObject addressInfo = null;
                        JSONObject jsonresult = null;
                        if (item.getString("headline").indexOf("省") > 0) {
                            warningBo.setProvince(item.getString("headline").substring(0, item.getString("headline").indexOf("省") + 1));
                        }
                        warningBo.setCity("");
                        if (item.getString("headline").indexOf("市") > 0) {
                            warningBo.setCity(item.getString("headline").substring(0, item.getString("headline").indexOf("市") + 1));
                        }
                        warningBo.setDistrict("");
                        if (item.getString("headline").indexOf("县") > 0) {
                            warningBo.setDistrict(item.getString("headline").substring(0, item.getString("headline").indexOf("县") + 1));
                        }
                        if (item.getString("headline").indexOf("区") > 0) {
                            warningBo.setDistrict(item.getString("headline").substring(0, item.getString("headline").indexOf("区") + 1));
                        }
                        if (item.getString("headline").indexOf("州") > 0) {
                            warningBo.setDistrict(item.getString("headline").substring(0, item.getString("headline").indexOf("州") + 1));
                        }
                        if (warningBo.getProvince() == null || warningBo.getProvince().length() < 2 || warningBo.getProvince() == "") {
                            ConcurrentHashMap map = new ConcurrentHashMap();
                            if (warningBo.getCity() != null && warningBo.getCity().length() > 2) {
                                map = getLatAndLngByAddr(warningBo.getCity());
                            }
                            if (warningBo.getDistrict() != null && warningBo.getDistrict().length() > 2) {
                                map = getLatAndLngByAddr(warningBo.getDistrict());
                            }
                            if (map.get("lng") != null && map.get("lat") != null) {
                                warningBo.setLongitude(String.valueOf(map.get("lng")));
                                warningBo.setLatitude(String.valueOf(map.get("lat")));
                                addressInfo = getAddressInfo(String.valueOf(map.get("lng")), String.valueOf(map.get("lat")));
                                if (addressInfo != null) {
                                    jsonresult = addressInfo.getJSONObject("result");
                                    if (jsonresult != null) {
                                        JSONObject addressComponent = jsonresult.getJSONObject("addressComponent");
                                        warningBo.setProvince(addressComponent.getString("province"));
                                        String city = addressComponent.getString("city");
                                        city = city.indexOf("省") > 0 ? city.substring(city.indexOf("省") + 1) : city;
                                        warningBo.setCity(city);
                                        warningBo.setDistrict(addressComponent.getString("county"));
                                        warningBo.setDisasterAddress(addressComponent.getString("province") + addressComponent.getString("city") + addressComponent.getString("county"));
                                    }
                                }
                            }
                        }
                        warningBo.setProvince("贵州省");
                        if (warningBo.getDistrict().equals("贵州")) {
                            warningBo.setDistrict(null);
                        }
                        warningBo.setInformationmedia("贵州省气象局");
                        warningBo.setDisasterStatus("灾害");
                        if (item.getString("event_type") != null) {
                            warningBo.setPicurl(item.getString("event_type") + "_" + item.getString("severity").toUpperCase() + ".png");
                        } else {
                            warningBo.setPicurl("other.png");
                        }
                        //  warningBo.setEventPicUrl(item.getString("severity"));
                        String type = typeMap.get(item.getString("event_type"));
                        warningBo.setDisasterType(type);
                        if (type != null && type.indexOf("事件") > 0) {
                            warningBo.setDisasterType(type.replaceAll("事件", ""));
                        }
                        //没有类型的再处理
                        warningBo.setDisasterType(warningBo.getDisasterType() == null ? "其他" : warningBo.getDisasterType());
                        if (warningBo.getPicurl().contains("UNKNOWN") || warningBo.getDisasterType().equals("其他") || warningBo.getPicurl().contains("11D08")) //
                        {
                            warningBo.setPicurl("other.png");
                        }
                        warningBo.setAddperson("祥云AI");
                        warningBo.setAddphone("15555555555");
                        //添加人等
                        Date day = new Date();
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        warningBo.setAddtime(sdf.format(day));
                        // emergencyInfoList.add(warningBo);
                        warningBoList.add(warningBo);
                        wxSpiderEmergencyInformationService.insert(warningBoList);
                        warningBoList.clear();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
            pageNumber++;
        }
    }


    /**
     * 贵州省自然资源厅气象预警信息
     *
     * @return
     */
    @At("/naturalmeteorologicalwarning")
    @Ok("json")
    @GET
    @ApiOperation(name = "贵州省自然资源厅气象预警信息")
    @SaCheckLogin
    private Result<Void> naturalmeteorologicalwarning() {
        int pageNumber = 1, pageSize = 50;
        List<WxSpiderEmergencyInformation> warningBoList = new ArrayList<>();
        while (true) {
            Map<String, Object> params = new HashMap<>();
            params.put("pageNumber", pageNumber);
            params.put("pageSize", pageSize);
            String result = HttpUtils.getRequest("http://140.210.211.155:8089/datapi/naturalwarning/meteorologicalwarningquery", params);
            JSONObject jsonObject = JSONObject.parseObject(result);
            JSONObject dataJson = jsonObject.getJSONObject("data");
            JSONObject pagerJson = dataJson.getJSONObject("pager");
            int pageCount = pagerJson.getInteger("pageCount");
            if (pageNumber > pageCount) {
                break;
            }
            JSONArray listJson = dataJson.getJSONArray("list");
            for (int i = 0; i < listJson.size(); i++) {
                JSONObject item = listJson.getJSONObject(i);
                String forecasterword = item.getString("forecasterword");
                String[] forecasterwordlist = forecasterword.split(";");
                String informationcontent = "";
                String times = "";
                if (forecasterword.indexOf("，") > 0) {
                    times = forecasterword.substring(0, forecasterword.indexOf("，") + 1);
                }
                for (int j = 0; j < forecasterwordlist.length; j++) {
                    String title = forecasterwordlist[j];

                    if (title.indexOf("地质灾害") > 0) {
                        title = title.substring(title.indexOf("地质灾害"));
                    }
                    String[] information = forecasterwordlist[j].split("、");
                    for (int k = 0; k < information.length; k++) {
//                        try {
//                            Thread.sleep(3000);
//                        } catch (InterruptedException e) {
//                            throw new RuntimeException(e);
//                        }
                        informationcontent = times;
                        String informationchannels = information[k].replaceAll("我省", "");
                        String district = null;//县
                        if (informationchannels.indexOf("，") > 0) {
                            Integer ii = informationchannels.indexOf("，");
                            Integer i2 = informationchannels.length();
                            district = informationchannels.substring(ii + 1, i2);
                        }
                        if (district != null && district.indexOf("地质灾害") > 0) {
                            informationchannels = district.substring(0, district.indexOf("地质灾害"));
                        }
                        district = informationchannels;
                        if (informationchannels != null && informationchannels.indexOf("地质灾害") > 0) {
                            informationchannels = informationchannels.substring(0, informationchannels.indexOf("地质灾害"));
                        }
                        if (informationchannels != null && informationchannels.indexOf("，") > 0) {
                            informationchannels = informationchannels.substring(informationchannels.indexOf("，"));
                        }
                        informationchannels = informationchannels + title;
                        informationcontent = informationcontent + informationchannels;
                        WxSpiderEmergencyInformation warningBo = new WxSpiderEmergencyInformation();
                        warningBo.setInformationtitle(informationchannels);//标题
                        warningBo.setReleasetime(((Timestamp) item.getTimestamp("recordtime"))); //发布时间
                        List<WxSpiderEmergencyInformation> list = new ArrayList<>(); //iWxSpiderEmergencyInformationService.queryList(warningBo);
                        if (list.size() < 1) {
                            try {
                                warningBo.setInformationcontent(informationcontent);//内容
                                informationcontent = "";
                                if (informationchannels != null && informationchannels.indexOf("（") > 0 && informationchannels.indexOf("）") > 0) {
                                    warningBo.setDisasterClass(informationchannels.substring(informationchannels.indexOf("（") + 1, informationchannels.indexOf("）")));
                                }
                                warningBo.setInformationchannels("贵州省自然资源厅");//气象局
                                JSONObject addressInfo = null;
                                JSONObject jsonresult = null;
                                if (district != null) {
                                    ConcurrentHashMap map = new ConcurrentHashMap();
                                    map = getLatAndLngByAddr(district);
                                    if (map.get("lng") != null && map.get("lat") != null) {
                                        warningBo.setLongitude(String.valueOf(map.get("lng")));
                                        warningBo.setLatitude(String.valueOf(map.get("lat")));
                                        addressInfo = getAddressInfo(String.valueOf(map.get("lng")), String.valueOf(map.get("lat")));
                                        if (addressInfo != null) {
                                            jsonresult = addressInfo.getJSONObject("result");
                                            if (jsonresult != null) {
                                                JSONObject addressComponent = jsonresult.getJSONObject("addressComponent");
                                                warningBo.setProvince(addressComponent.getString("province"));
                                                String city = addressComponent.getString("city");
                                                city = city.indexOf("省") > 0 ? city.substring(city.indexOf("省") + 1) : city;
                                                warningBo.setCity(city);
                                                warningBo.setDistrict(addressComponent.getString("county"));
                                                warningBo.setDisasterAddress(addressComponent.getString("province") + addressComponent.getString("city") + addressComponent.getString("county"));
                                            }
                                        }
                                    }
                                }
                                warningBo.setProvince("贵州省");
                                warningBo.setInformationmedia("贵州省自然资源厅");
                                warningBo.setDisasterStatus("灾害");
//                                if(item.getString("event_type")!=null) {
//                                    warningBo.setPicurl(item.getString("event_type")+"_"+item.getString("severity").toUpperCase() + ".png");
//                                }else{
//                                    warningBo.setPicurl("other.png");
//                                }
                                //  warningBo.setEventPicUrl(item.getString("severity"));
                                warningBo.setDisasterType("地质灾害");
                                //没有类型的再处理
                                warningBo.setPicurl("other.png");
                                warningBo.setAddperson("祥云AI");
                                warningBo.setAddphone("15555555555");
                                //添加人等
                                Date day = new Date();
                                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                                warningBo.setAddtime(sdf.format(day));
                                // emergencyInfoList.add(warningBo);
                                warningBoList.add(warningBo);
                                //  iWxSpiderEmergencyInformationService.insertBatch(warningBoList);
                                warningBoList.clear();
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }
                }
            }
            pageNumber++;
        }

        return Result.success();
    }


    /**
     * 贵州省交通厅
     *
     * @return
     */
    @At("/trafficblocknews")
    @Ok("json")
    @GET
    @ApiOperation(name = "贵州省自然资源厅气象预警信息")
    @SaCheckLogin
    private Result<Void> trafficblocknews() {
        System.out.println("贵州省交通运输厅: " + new Date());
        int pageNumber = 1, pageSize = 50;
        List<WxSpiderEmergencyInformation> warningBoList = new ArrayList<>();
        while (true) {
            Map<String, Object> params = new HashMap<>();
            params.put("pageNumber", pageNumber);
            params.put("pageSize", pageSize);
            String result = HttpUtils.getRequest("http://140.210.211.155:8089/datapi/trafficroad/trafficblocknews", params);
            JSONObject jsonObject = JSONObject.parseObject(result);
            JSONObject dataJson = jsonObject.getJSONObject("data");
            JSONObject pagerJson = dataJson.getJSONObject("pager");
            int pageCount = pagerJson.getInteger("pageCount");
            if (pageNumber > pageCount) {
                break;
            }
            JSONArray listJson = dataJson.getJSONArray("list");
            for (int i = 0; i < listJson.size(); i++) {
                JSONObject item = listJson.getJSONObject(i);
                WxSpiderEmergencyInformation warningBo = new WxSpiderEmergencyInformation();
                warningBo.setInformationtitle(item.getString("f_20216323178_ext"));//标题
                if (warningBo.getInformationtitle() == null) {
                    warningBo.setInformationtitle(item.getString("f_20216323178"));//标题
                    System.out.println(item);
                }
                if (warningBo.getInformationtitle() == null) {
                    System.out.println(item);
                }
                warningBo.setReleasetime(((Timestamp) item.getTimestamp("save_time"))); //发布时间
                List<WxSpiderEmergencyInformation> list = new ArrayList<>(); //iWxSpiderEmergencyInformationService.queryList(warningBo);
                if (list.size() < 1) {
                    try {
                        warningBo.setInformationcontent(item.getString("f_202163172887").replaceAll(" ", ""));//内容
                        warningBo.setInformationchannels(item.getString("f_202163599791_ext"));//信息来源
                        warningBo.setProvince("贵州省");
                        warningBo.setDisasterAddress("贵州省");
                        warningBo.setInformationmedia("贵州省交通运输厅");
                        warningBo.setDisasterStatus("灾害");
                        warningBo.setDisasterType("阻断信息");
                        //没有类型的再处理
                        warningBo.setPicurl("other.png");
                        warningBo.setAddperson("祥云AI");
                        warningBo.setAddphone("15555555555");
                        //添加人等
                        Date day = new Date();
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        warningBo.setAddtime(sdf.format(day));
                        warningBo.setIsshow("1");//不显示
                        warningBoList.add(warningBo);
                        //iWxSpiderEmergencyInformationService.insertBatch(warningBoList);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
            pageNumber++;
        }
        warningBoList.clear();
        return Result.success();
    }


    /**
     * 获取token
     *
     * @return
     */
    @At("/getaccesstoken")
    @Ok("json")
    @GET
    @ApiOperation(name = "获取token")
    @SaCheckLogin
    private String getOauthToken() {
        String requestUrl = "http://58.42.237.172:8188/api/system/oauth/token?username=xytb&password=vJZzem7jr78hWGLAmdmf5w==&code=0&grant_type=password&scope=server";
        try {
            String loginresult = HttpRequest.post(requestUrl).header("terminal", "companion").execute().body();
            JSONObject jsonObject = JSONObject.parseObject(loginresult);
            return jsonObject.getString("access_token");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }


    /**
     * 贵州省水利厅
     *
     * @return
     */
    @At("/regionwarning")
    @Ok("json")
    @GET
    @ApiOperation(name = "贵州省水利厅")
    @SaCheckLogin
    private Result<Void> regionwarning() {
        try {
            int pageNumber = 1, pageSize = 50;
            List<WxSpiderEmergencyInformation> warningBoList = new ArrayList<>();
            String token = getOauthToken();
            if (token == null) {
                System.out.println("获取token出错");
            }
            token = "Bearer " + token;

            String requestUrl = "http://58.42.237.172:8188/api/station-service/regionWarning/infoList";
            Date newday = new Date();
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            String times = df.format(newday);
            for (int m = 0; m < 5; m++) {
                if (m > 0) {
                    newday.setHours(newday.getHours() - 24);
                }
                times = df.format(newday);
                System.out.println(times);
                while (true) {

                    JSONObject jsonCode = new JSONObject();
                    JSONObject pageData = new JSONObject();
                    JSONObject regionParam = new JSONObject();
                    pageData.put("pageSize", 20);
                    pageData.put("pageNow", pageNumber);
                    regionParam.put("startTime", times);
                    regionParam.put("adcd", "520000000000000");
                    String[] statuses = {"0", "1", "2", "3", "4", "5", "6", "7"};
                    regionParam.put("statuses", statuses);
                    jsonCode.put("pageData", pageData);
                    jsonCode.put("regionParam", regionParam);
                    String result = HttpRequest.post(requestUrl).header("Authorization", token).body(jsonCode.toJSONString()).execute().body();
                    JSONObject jsonObject = JSONObject.parseObject(result);
                    Integer code = jsonObject.getInteger("code");
                    String msg = jsonObject.getString("msg");
                    JSONObject dataJson = jsonObject.getJSONObject("data");
                    if (code != 0) {
                        System.out.println("获取水利厅接口数据出错" + msg);
                        break;
                    }
                    int pageCount = dataJson.getInteger("pages");
                    if (pageNumber > pageCount) {
                        break;
                    }
                    JSONArray listJson = dataJson.getJSONArray("source");
                    System.out.println("result: " + listJson);
                    for (int i = 0; i < listJson.size(); i++) {
                        JSONObject item = listJson.getJSONObject(i);
                        WxSpiderEmergencyInformation warningBo = new WxSpiderEmergencyInformation();

                        String title = item.getString("city") + item.getString("county") + item.getString("town") + item.getString("warnName");
                        warningBo.setInformationtitle(title);//标题
                        warningBo.setReleasetime(((Timestamp) item.getTimestamp("warnDT"))); //发布时间
                        List<WxSpiderEmergencyInformation> list = new ArrayList<>();// iWxSpiderEmergencyInformationService.queryList(warningBo);
                        if (list.size() < 1) {
                            try {
                                warningBo.setInformationcontent(item.getString("warnContent"));//内容
                                warningBo.setInformationchannels("贵州省水利厅");//信息来源
                                warningBo.setInformationmedia("贵州省水利厅");
                                warningBo.setDisasterStatus("灾害");
                                warningBo.setProvince("贵州省");
                                warningBo.setCity(item.getString("city"));
                                warningBo.setDistrict(item.getString("county"));
                                warningBo.setStreet(item.getString("town"));
                                warningBo.setLatitude(item.getString("lttd"));
                                warningBo.setLongitude(item.getString("lgtd"));
                                warningBo.setDisasterType("山洪预警");
                                String warnName = item.getString("warnName");
                                if (warnName.indexOf("(") > 0 && warnName.indexOf(")") > 0) //等级，准备转移，立即转移  //白纸厂二组(准备转移)
                                {
                                    warningBo.setDisasterClass(warnName.substring(warnName.indexOf("(") + 1, warnName.indexOf(")")));
                                }
                                //没有类型的再处理
                                warningBo.setPicurl("other.png");
                                warningBo.setAddperson("祥云AI");
                                warningBo.setAddphone("15555555555");
                                //添加人等
                                Date day = new Date();
                                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                                warningBo.setAddtime(sdf.format(day));
                                warningBo.setIsshow("1");//不显示
                                warningBoList.add(warningBo);
                                System.out.println("warningBoList: " + warningBoList);
                                //  iWxSpiderEmergencyInformationService.insertBatch(warningBoList);
                                warningBoList.clear();
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }
                    pageNumber++;
                    if (pageNumber > pageCount) {
                        break;
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.success();
    }

    /**
     * 贵州省水利厅,山洪气象
     *
     * @return
     */
    @At("/findWeatherRiskByPage")
    @Ok("json")
    @GET
    @ApiOperation(name = "贵州省水利厅,山洪气象")
    @SaCheckLogin
    private Result<Void> findWeatherRiskByPage() {
        try {
            System.out.println("贵州省水利厅 山洪气象预警");
            int pageNumber = 1, pageSize = 50;
            List<WxSpiderEmergencyInformation> warningBoList = new ArrayList<>();
            String token = getOauthToken();
            if (token == null) {
                System.out.println("获取token出错");
            }
            token = "Bearer " + token;

            String requestUrl = "http://58.42.237.172:8188/api/station-service/weatherrisk/findWeatherRiskByPage";
            Date newday = new Date();
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String endTime = df.format(newday);
            newday.setHours(newday.getHours() - 72);
            String startTime = df.format(newday);
            while (true) {
                JSONObject jsonCode = new JSONObject();
                //{"adcd":"520000000000000","startTime":"2023-04-20 20:00:00","endTime":"2023-04-26 20:00:00","warnType":"","page":1,"size":50}
                jsonCode.put("adcd", "520000000000000");
                jsonCode.put("startTime", startTime);
                jsonCode.put("endTime", endTime);
                jsonCode.put("warnType", "");
                jsonCode.put("page", pageNumber);
                jsonCode.put("size", pageSize);
                String result = HttpRequest.post(requestUrl).header("Authorization", token).body(jsonCode.toJSONString()).execute().body();
                JSONObject jsonObject = JSONObject.parseObject(result);
                Integer code = jsonObject.getInteger("code");
                String msg = jsonObject.getString("msg");
                JSONObject dataJson = jsonObject.getJSONObject("data");
                if (code != 0) {
                    System.out.println("获取水利厅接口数据出错" + msg);
                    break;
                }
                int pageCount = dataJson.getInteger("pages");
                if (pageNumber > pageCount) {
                    break;
                }
                JSONArray listJson = dataJson.getJSONArray("rows");
                for (int i = 0; i < listJson.size(); i++) {
                    JSONObject item = listJson.getJSONObject(i);
                    String forecasterword = item.getString("forecasts");
                    if (forecasterword.contains("预计")) {
                        forecasterword = forecasterword.replaceAll("预计，", "");
                        forecasterword = forecasterword.replaceAll("预计,", "");
                    }
                    if (forecasterword.contains("山洪灾害风险较小")) {
                        continue;
                    }
                    String times = "";
                    if (forecasterword.indexOf("白天,") > 0) {
                        times = forecasterword.substring(0, forecasterword.indexOf("白天,") + 2);
                        forecasterword = forecasterword.substring(forecasterword.indexOf("白天,") + 3);
                    }
                    if (times.length() < 2 && forecasterword.indexOf("月") > 0 && forecasterword.indexOf("日") > 0 && forecasterword.indexOf("时") > 0) {
                        if (forecasterword.indexOf("时,") > 0) {
                            times = forecasterword.substring(0, forecasterword.indexOf("时,"));
                            forecasterword = forecasterword.substring(forecasterword.indexOf("时,") + 1);
                        }
                        if (forecasterword.indexOf("时，") > 0) {
                            times = forecasterword.substring(0, forecasterword.indexOf("时，") + 1);
                            forecasterword = forecasterword.substring(forecasterword.indexOf("时，") + 2);
                        }
                    }
                    String[] forecasterwordlist = forecasterword.split("。");
                    String informationcontent = "";
                    for (int j = 0; j < forecasterwordlist.length; j++) {
                        String title = forecasterwordlist[j];
                        String end = title;
                        if (title.indexOf("可能发生") > 0) {
                            end = title.substring(title.indexOf("可能发生"));
                            title = title.substring(0, title.indexOf("可能发生"));
                        }
                        if (title.indexOf("发生") > 0) {
                            end = title.substring(title.indexOf("发生"));
                            title = title.substring(0, title.indexOf("发生"));
                        }
                        if (end.equals(title))
                            continue;
                        title = title.replaceAll("，", "、");
                        String[] information = title.split("、");
                        for (int k = 0; k < information.length; k++) {
                            try {
                                Thread.sleep(5000);
                            } catch (InterruptedException e) {
                                throw new RuntimeException(e);
                            }
                            String informationchannels = information[k].replaceAll("我省", "");
                            String district = informationchannels;//县
                            if (district.indexOf("月") > 0 && district.indexOf("日") > 0)
                                continue;
                            if (district.indexOf("预警：") > 0)
                                district = district.substring(district.indexOf("预警：") + 3);
                            if (district.indexOf("预警:") > 0)
                                district = district.substring(district.indexOf("预警:") + 3);
                            informationcontent = district + end;
                            if (informationcontent.indexOf(",") == 0)
                                informationcontent.replace(",", "");
                            WxSpiderEmergencyInformation warningBo = new WxSpiderEmergencyInformation();
                            warningBo.setInformationtitle(informationcontent);//标题
                            warningBo.setReleasetime(((Timestamp) item.getTimestamp("warnTime"))); //发布时间
                            List<WxSpiderEmergencyInformation> list = new ArrayList<>(); //iWxSpiderEmergencyInformationService.queryList(warningBo);
                            if (list.size() < 1) {
                                try {
                                    System.out.println("贵州省水利厅 山洪气象预警： " + informationcontent);
                                    warningBo.setDisasterClass(item.getString("wlevelStr") + "预警");
                                    warningBo.setInformationchannels("贵州省水利厅");//气象局
                                    JSONObject addressInfo = null;
                                    JSONObject jsonresult = null;
                                    if (district != null) {
                                        ConcurrentHashMap map = new ConcurrentHashMap();
                                        map = getLatAndLngByAddr(district);
                                        if (map.get("lng") != null && map.get("lat") != null) {
                                            warningBo.setLongitude(String.valueOf(map.get("lng")));
                                            warningBo.setLatitude(String.valueOf(map.get("lat")));
                                            addressInfo = getAddressInfo(String.valueOf(map.get("lng")), String.valueOf(map.get("lat")));
                                            if (addressInfo != null) {
                                                jsonresult = addressInfo.getJSONObject("result");
                                                if (jsonresult != null) {
                                                    JSONObject addressComponent = jsonresult.getJSONObject("addressComponent");
                                                    warningBo.setProvince(addressComponent.getString("province"));
                                                    String city = addressComponent.getString("city");
                                                    city = city.indexOf("省") > 0 ? city.substring(city.indexOf("省") + 1) : city;
                                                    warningBo.setCity(city);
                                                    warningBo.setDistrict(addressComponent.getString("county"));
                                                    warningBo.setDisasterAddress(addressComponent.getString("province") + addressComponent.getString("city") + addressComponent.getString("county"));
                                                }
                                            }
                                        }
                                    }
                                    warningBo.setInformationcontent(district + "," + end);//内容
                                    if (times.length() > 2)
                                        warningBo.setInformationcontent(times + "," + district + "," + end);//内容

                                    if (warningBo.getDisasterAddress() != null) {
                                        warningBo.setInformationcontent(times + "," + warningBo.getDisasterAddress() + "," + end);//内容
                                    }
                                    warningBo.setProvince("贵州省");
                                    warningBo.setInformationmedia("贵州省水利厅");
                                    warningBo.setDisasterStatus("灾害");
                                    warningBo.setDisasterType("山洪气象预警");
                                    //没有类型的再处理
                                    warningBo.setPicurl("other.png");
                                    warningBo.setAddperson("祥云AI");
                                    warningBo.setAddphone("15555555555");
                                    //添加人等
                                    Date day = new Date();
                                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                                    warningBo.setAddtime(sdf.format(day));
                                    warningBoList.add(warningBo);
                                    // iWxSpiderEmergencyInformationService.insertBatch(warningBoList);
                                    warningBoList.clear();
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        }
                    }
                }
                pageNumber++;
                if (pageNumber > pageCount) {
                    break;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.success();
    }


    /**
     * 邮件发送
     *
     * @return
     */
    @At("/sendText")
    @Ok("json")
    @GET
    @ApiOperation(name = "邮件发送")
    @SaCheckLogin
    private Result<Void> sendText() {
        try {
            MailUtils.sendText("850715177@qq.com", "测试邮件发送", "测试邮件发送");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.success();
    }
}
